﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication33
{
    class io
    {

      




          

            public List<Person> wczytajklucze()
            {
                string line;
                System.IO.StreamReader file =new System.IO.StreamReader("test.txt");
                line = file.ReadLine();
                 string[] temp=line.Split(' ');

                
                 List<Person> osoby = new List<Person>();

                int k = 0;
                List<string> ss = new List<string>();
                foreach(string s in temp)
                {
                   
                   string[] temporary=s.Split(',');
                   ss.AddRange(temporary.ToList());

                }
                int[] ulubione = new int[temp.Length];

                for(int i=0;i<ss.Count;i+=2)
                {
                    ulubione[int.Parse(ss[i]) - 1] = i / 2;
                }
                osoby.Add(new Person(null,ulubione,0));

                int indexer = 1;
               

                int[,] tablica_kobiet = new int[temp.Length, temp.Length];

                int x = 0;
                for (int i = 1; i < ss.Count; i += 2)
                {
                    tablica_kobiet[0, x] =int.Parse( ss[i]);
                    x++;
                    
                }


                int y = 1;

                while ((line = file.ReadLine()) != null)
                {
                    ss = new List<string>();
                    temp = line.Split(' ');

                    foreach (string s in temp)
                    {

                        string[] temporary = s.Split(',');
                        ss.AddRange(temporary.ToList());

                    }
                    ulubione = new int[temp.Length];

                    for (int i = 0; i < ss.Count; i += 2)
                    {
                        ulubione[int.Parse(ss[i]) - 1] = i / 2;
                    }
                    osoby.Add(new Person(null, ulubione, indexer++));




                    x = 0;
                   
                    for (int i = 1; i < ss.Count; i += 2)
                    {
                        tablica_kobiet[y, x] = int.Parse(ss[i]);
                        x++;

                    }
                    y++;
                   

                   
                }
                indexer = 0;

                for (int m = 0; m < y; m++)
                {
                    ulubione = new int[temp.Length];

                  
                        for (int j = 0; j < y; j++)
                        {
                            ulubione[tablica_kobiet[j, m]-1]=j;
                        }
                    
                    osoby.Add(new Person(null, ulubione, indexer++));

                }




                return osoby;
            }

    

           



       




    }
}
